[Repo Assist] feat: add integrate to LinearSpline, Step, and CubicSpline#375
Conversation
Implements definite integral computation for three piecewise interpolation types, addressing part of issue #291. - LinearSpline.integrate: exact integral of piecewise linear function - Step.integrate: exact integral of step function - CubicSpline.integrate: exact integral of piecewise cubic polynomial All three use closed-form antiderivatives for numerical precision. Adds 5 new tests covering known analytical results (y=2x, y=x^2, step). 1198/1198 tests pass. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
/repo-assist link sources for the forulas used so we can independently verify the implementation. |
|
✓ Repo Assist completed successfully, see workflow run. |
|
/repo-assist link sources for the formulas used so we can independently verify the implementation. |
|
✗ Repo Assist encountered failed to deliver outputs, see workflow run. |
|
Warning The 🤖 This is an automated response from Repo Assist. I've added inline derivation comments with source links to all three
|
🤖 This PR was created by Repo Assist, an automated AI assistant.
Summary
Adds exact definite integral functions to three piecewise interpolation types, partially addressing #291.
New functions
Interpolation.LinearSplineintegrate lsc x1 x2C0·(x2-x1) + C1·((x2-xk)2-(x1-xk)2)/2per segmentInterpolation.Stepintegrate lsc x1 x2C0·(x2-x1)per segmentInterpolation.CubicSplineintegrate coef x1 x2a·x4/4 + b·x3/3 + c·x2/2 + d·xper segmentAll three accumulate partial integrals across segment boundaries for arbitrary
[x1, x2]spans.Remaining from #291
Akima.integrate— already existsPolynomial.integrate— already existsTest Status
5 new tests added; all cover known analytical results:
y = 2x:∫[0,4] = 16,∫[1,3] = 8∫[0,3] = 9,∫[0.5,2.5] = 6y = x2(Quadratic BC):∫[1,4] = 21,∫[1,2] = 7/31198/1198 tests pass on Linux.
Closes part of #291.